/*
*
* 获取当前登录的用户名，传到前端，zzy
*
* */


package servlet;
import domain.User;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "getUsernameZZY", value = "/getUsernameZZY")
public class getUsernameZZY extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        User user = (User) req.getSession().getAttribute("user");
        String username = user.getUsername();
        resp.getWriter().write(username);
    }
}
